﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace Saturn.App.Common
{
    public class SystemCalls
    {

        //更多按键请参考 http://msdn2.microsoft.com/en-us/library/ms927178.aspx

        public const byte VK_NONAME = 0xFC; // 什么也不做

        public const byte VK_PAUSE = 13; //回车键

        public const byte VK_ESC = 0x1B; // Smartphone的回退键

        public const byte VK_F4 = 0x73; // Home Screen

        public const byte VK_APP6 = 0xC6; // Smartphone上锁定键盘

        public const byte VK_F22 = 0x85; // PocketPC上锁定键盘 (VK_KEYLOCK)

        public const byte VK_F16 = 0x7F; // 出发扬声器

        public const byte VK_OFF = 0x7F; //电源键

        /// <summary>

        /// 将按键送至全局键盘缓冲区

        /// </summary>

        /// <param name="key"></param>

        public static void SendKey(byte key)
        {

            //const byte KEYEVENTF_SILENT = 0x0004;

            const int KEYEVENTF_KEYUP = 0x02;

            const int KEYEVENTF_KEYDOWN = 0x00;

            keybd_event(key, 0, KEYEVENTF_KEYDOWN, 0);

            keybd_event(key, 0, KEYEVENTF_KEYUP, 0);

        }

        [DllImport("coredll", SetLastError = true)]

        private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

    }
}
